<%
    /** 
     * 打印记录
     */
%>
<%  logger.info("2. 构造记录明细区");
    logger.debug("  -- 取记录明细区");
    ItemListArea ilArea = (ItemListArea)request.getAttribute("viewer");
    logger.debug("  -- 取翻页器");
    ValueListHandler valueListHandler  = (ValueListHandler)request.getAttribute("valueListHandler");
    logger.debug("  -- 翻页");
    List models = valueListHandler.getList();
    logger.debug("  -- 显示记录明细");
    
	// 创建HSSFFont(注意：一定要放在前面定义，不能放在for循环里面)
	/** 1设置12号字体，不加粗 **/
	HSSFFont itemFont1 = wb.createFont();
	itemFont1.setFontHeightInPoints((short)12);
	/** 2设置12号字体，并加粗 **/
	HSSFFont itemFont2 = wb.createFont();
	itemFont2.setFontHeightInPoints((short)12);
	itemFont2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 普通粗
	// 创建HSSFCellStyle(注意：一定要放在前面定义，不能放在for循环里面)
	// 经过分析有3中风格
	/** 1设置左局风格，不加粗 **/
	HSSFCellStyle itemStyle1 = wb.createCellStyle();
	itemStyle1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 上下:居中
    itemStyle1.setBorderTop(HSSFCellStyle.BORDER_THIN);
    itemStyle1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    itemStyle1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    itemStyle1.setBorderRight(HSSFCellStyle.BORDER_THIN);
	itemStyle1.setAlignment(HSSFCellStyle.ALIGN_LEFT);
	itemStyle1.setFont(itemFont1);
	/** 2设置右局风格，不加粗 **/
    HSSFCellStyle itemStyle2 = wb.createCellStyle();
	itemStyle2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 上下:居中
    itemStyle2.setBorderTop(HSSFCellStyle.BORDER_THIN);
    itemStyle2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    itemStyle2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    itemStyle2.setBorderRight(HSSFCellStyle.BORDER_THIN);
	itemStyle2.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
	itemStyle2.setFont(itemFont1);
	/** 3设置居中风格，并加粗 **/
	HSSFCellStyle itemStyle3 = wb.createCellStyle();
	itemStyle3.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 上下:居中
    itemStyle3.setBorderTop(HSSFCellStyle.BORDER_THIN);
    itemStyle3.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    itemStyle3.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    itemStyle3.setBorderRight(HSSFCellStyle.BORDER_THIN);
	itemStyle3.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	itemStyle3.setFont(itemFont2);
	/** 其他的风格现在还没用，我先把它全部穷举完 **/
	/** 4设置左局风格，并加粗**/
	HSSFCellStyle itemStyle4 = wb.createCellStyle();
	itemStyle4.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 上下:居中
    itemStyle4.setBorderTop(HSSFCellStyle.BORDER_THIN);
    itemStyle4.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    itemStyle4.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    itemStyle4.setBorderRight(HSSFCellStyle.BORDER_THIN);
	itemStyle4.setAlignment(HSSFCellStyle.ALIGN_LEFT);
	itemStyle4.setFont(itemFont2);
	/** 5设置右局风格，并加粗**/
	HSSFCellStyle itemStyle5 = wb.createCellStyle();
	itemStyle5.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 上下:居中
    itemStyle5.setBorderTop(HSSFCellStyle.BORDER_THIN);
    itemStyle5.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    itemStyle5.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    itemStyle5.setBorderRight(HSSFCellStyle.BORDER_THIN);
	itemStyle5.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
	itemStyle5.setFont(itemFont2);
	/** 6设置居中风格，不加粗**/
	HSSFCellStyle itemStyle6 = wb.createCellStyle();
	itemStyle6.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 上下:居中
    itemStyle6.setBorderTop(HSSFCellStyle.BORDER_THIN);
    itemStyle6.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    itemStyle6.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    itemStyle6.setBorderRight(HSSFCellStyle.BORDER_THIN);
	itemStyle6.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	itemStyle6.setFont(itemFont1);

    if(columns == null)
    {
		System.out.print("=======现在还没有启用定制列的功能=======");
        for(int i = 0; i < models.size(); i ++)
        {
            HSSFRow itemRow = sheet.createRow((short) reportHeight + 2 + maxDepth + i);
            List items = ilArea.getItems(request.getContextPath(),(BaseObject)models.get(i));
            int index4Item = 0;
            for(int j = 0; j < items.size(); j ++)
            {
                Item item = (Item)items.get(j);
                if(item.getPrinted())
                {
                    HSSFCell itemCell = itemRow.createCell((short)index4Item);
                    itemCell.setEncoding(HSSFCell.ENCODING_UTF_16);
                    itemCell.setCellValue(item.getText());
					/*
                    //HSSFCellStyle itemStyle = wb.createCellStyle();
                    itemStyle.setAlignment(FontLayOut.EXCEL_LAY_OUT_TABS[item.getXLayOut()]); // 左右:
                    itemStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 上下:居中
                    itemStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
                    //HSSFFont itemFont = wb.createFont(); // 标题字体
                    //itemFont.setFontHeightInPoints((short)12); // 字体大小
                    if(item.isBold())
                    {
                        //itemFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 普通粗
                    }
                    itemStyle.setFont(itemFont);
					*/
					if(item.getXLayOut() == FontLayOut.LEFT && !item.isBold())
                        itemCell.setCellStyle(itemStyle1);
					if(item.getXLayOut() == FontLayOut.RIGHT && !item.isBold())
                        itemCell.setCellStyle(itemStyle2);
					if(item.getXLayOut() == FontLayOut.CENTER && item.isBold())
                        itemCell.setCellStyle(itemStyle3);
					if(item.getXLayOut() == FontLayOut.CENTER && !item.isBold())
                        itemCell.setCellStyle(itemStyle6);
					if(item.getXLayOut() == FontLayOut.LEFT && item.isBold())
                        itemCell.setCellStyle(itemStyle4);
					if(item.getXLayOut() == FontLayOut.RIGHT && item.isBold())
                        itemCell.setCellStyle(itemStyle5);
                    index4Item ++;
                }
                else
                {
                    continue;
                }
            }// for  j
        }// for i
		
        logger.debug("合计");
        List items4Total = ilArea.getTotal(request.getContextPath(),valueListHandler.getList());
        if(items4Total.size() > 0)
        {
            HSSFRow itemRow = sheet.createRow((short) reportHeight + 2 + maxDepth + models.size());
            int index4Item = 0;
            for(int j = 0; j < items4Total.size(); j ++)
            {
                Item item = (Item)items4Total.get(j);
                if(item.getPrinted())
                {
                    HSSFCell itemCell = itemRow.createCell((short)index4Item);
                    itemCell.setEncoding(HSSFCell.ENCODING_UTF_16);
                    itemCell.setCellValue(item.getText());
					/*
                    //HSSFCellStyle itemStyle = wb.createCellStyle();
                    itemStyle.setAlignment(FontLayOut.EXCEL_LAY_OUT_TABS[item.getXLayOut()]); // 左右:
                    itemStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 上下:居中
                    itemStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
                    //HSSFFont itemFont = wb.createFont(); // 标题字体
                    //itemFont.setFontHeightInPoints((short)12); // 字体大小
                    if(item.isBold())
                    {
                        //itemFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 普通粗
                    }
                    itemStyle.setFont(itemFont);
					*/
					if(item.getXLayOut() == FontLayOut.LEFT && !item.isBold())
                        itemCell.setCellStyle(itemStyle1);
					if(item.getXLayOut() == FontLayOut.RIGHT && !item.isBold())
                        itemCell.setCellStyle(itemStyle2);
					if(item.getXLayOut() == FontLayOut.CENTER && item.isBold())
                        itemCell.setCellStyle(itemStyle3);
					if(item.getXLayOut() == FontLayOut.CENTER && !item.isBold())
                        itemCell.setCellStyle(itemStyle6);
					if(item.getXLayOut() == FontLayOut.LEFT && item.isBold())
                        itemCell.setCellStyle(itemStyle4);
					if(item.getXLayOut() == FontLayOut.RIGHT && item.isBold())
                        itemCell.setCellStyle(itemStyle5);
                    index4Item ++;
                }
                else
                {
                    continue;
                }
            }//  合计 for 
            
        }
        
    }// if
    else
    {
		System.out.println("======现在是在定制列那里执行======");
		System.out.println("***************长度=" + columns.length);
        for(int i = 0; i < models.size(); i ++)
        {
            HSSFRow itemRow = sheet.createRow((short)reportHeight + 2 + maxDepth + i);
            List items = ilArea.getItems(request.getContextPath(),(BaseObject)models.get(i));
            int index4Item = 0;
            for(int j = 0; j < columns.length; j ++)
            {
                Item item = (Item)items.get(Integer.parseInt(columns[j]));
                if(item.getPrinted())
                {
                    HSSFCell itemCell = itemRow.createCell((short)index4Item);
                    itemCell.setEncoding(HSSFCell.ENCODING_UTF_16);
                    itemCell.setCellValue(item.getText());
					/*
                    //HSSFCellStyle itemStyle = wb.createCellStyle();
                    itemStyle.setAlignment(FontLayOut.EXCEL_LAY_OUT_TABS[item.getXLayOut()]); // 左右:居中
                    itemStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 上下:居中
                    itemStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
                    //HSSFFont itemFont = wb.createFont(); // 标题字体
                    //itemFont.setFontHeightInPoints((short)12); // 字体大小
                    if(item.isBold())
                    {
                        //itemFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 普通粗
                    }
                    itemStyle.setFont(itemFont);
					*/
					if(item.getXLayOut() == FontLayOut.LEFT && !item.isBold())
                        itemCell.setCellStyle(itemStyle1);
					if(item.getXLayOut() == FontLayOut.RIGHT && !item.isBold())
                        itemCell.setCellStyle(itemStyle2);
					if(item.getXLayOut() == FontLayOut.CENTER && item.isBold())
                        itemCell.setCellStyle(itemStyle3);
					if(item.getXLayOut() == FontLayOut.CENTER && !item.isBold())
                        itemCell.setCellStyle(itemStyle6);
					if(item.getXLayOut() == FontLayOut.LEFT && item.isBold())
                        itemCell.setCellStyle(itemStyle4);
					if(item.getXLayOut() == FontLayOut.RIGHT && item.isBold())
                        itemCell.setCellStyle(itemStyle5);
                    index4Item++;
                }
                else
                {
                    continue;
                }
            }// for j
        }// for i
		
        logger.debug("合计");
        List items4Total = ilArea.getTotal(request.getContextPath(),valueListHandler.getList());
        if(items4Total.size() > 0)
        {
            HSSFRow itemRow = sheet.createRow((short) reportHeight + 2 + maxDepth + models.size());
            int index4Item = 0;
            for(int j = 0; j < columns.length; j ++)
            {
                Item item = (Item)items4Total.get(Integer.parseInt(columns[j]));
                if(item.getPrinted())
                {
                    HSSFCell itemCell = itemRow.createCell((short)index4Item);
                    itemCell.setEncoding(HSSFCell.ENCODING_UTF_16);
                    itemCell.setCellValue(item.getText());
					/*
                    //HSSFCellStyle itemStyle = wb.createCellStyle();
                    itemStyle.setAlignment(FontLayOut.EXCEL_LAY_OUT_TABS[item.getXLayOut()]); // 左右:
                    itemStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 上下:居中
                    itemStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                    itemStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
                    //HSSFFont itemFont = wb.createFont(); // 标题字体
                    //itemFont.setFontHeightInPoints((short)12); // 字体大小
                    if(item.isBold())
                    {
                        //itemFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 普通粗
                    }
                    itemStyle.setFont(itemFont);
					*/
					if(item.getXLayOut() == FontLayOut.LEFT && !item.isBold())
                        itemCell.setCellStyle(itemStyle1);
					if(item.getXLayOut() == FontLayOut.RIGHT && !item.isBold())
                        itemCell.setCellStyle(itemStyle2);
					if(item.getXLayOut() == FontLayOut.CENTER && item.isBold())
                        itemCell.setCellStyle(itemStyle3);
					if(item.getXLayOut() == FontLayOut.CENTER && !item.isBold())
                        itemCell.setCellStyle(itemStyle6);
					if(item.getXLayOut() == FontLayOut.LEFT && item.isBold())
                        itemCell.setCellStyle(itemStyle4);
					if(item.getXLayOut() == FontLayOut.RIGHT && item.isBold())
                        itemCell.setCellStyle(itemStyle5);
                    index4Item ++;
                }
                else
                {
                    continue;
                }
            }//  合计 for 
			
            %>
            </tr>    
            <%
        }
    }// else
%>
